# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Dimitris Kiziridis <ragouel at outlook dot com>
# Contributor: Christian Krause ("wookietreiber") <christian.krause@mailbox.org>

pkgname=freeorion
pkgver=0.5
pkgrel=3
pkgdesc='A turn-based space empire and galactic conquest game'
url='https://www.freeorion.org'
arch=('loong64' 'x86_64')
license=('GPL2')
depends=(
  'boost-libs'
  'python'
  'sdl2'
  'libvorbis'
  'glew'
  'openal'
  'hicolor-icon-theme'
  'freetype2'
)
makedepends=(
  'git'
  'cmake'
  'boost'
)
_commit='50eff8b4177d9aa4f500f7e8d58df7b5aaf24849'
source=(
  "$pkgname::git+https://github.com/freeorion/freeorion.git#commit=$_commit"
  'fix-version-string.patch'
)
sha512sums=('SKIP'
            'ab939c24e73f2a2907875d732dbd481914658e2ebf80d682a39cb5904c78591e1ce9b95dff50d1799c177017f525a90cfb2f0b7c77824954ee3b4197ca2381c4')
b2sums=('SKIP'
        'c87e0eefd36041a72340a7d31eb91c02e595fa875e032854d80cd6db079f8fcd208a655dfb2bc92376d654f862eafa1e9367045e81fee469398ac41356d4fedf')

pkgver() {
  cd "$pkgname"
  git describe --tags | sed 's/^v//'
}

prepare() {
  patch \
    --directory "$pkgname" \
    --strip=1 \
    --input=../fix-version-string.patch
}

build() {
  cmake \
    -B build \
    -S "$pkgname" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release

  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}
